package com.cskaoyan.service.wx;

import com.cskaoyan.bean.Region;
import com.cskaoyan.bean.RegionExample;
import com.cskaoyan.mapper.RegionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author heyyon
 */
@Service
public class WxRegionServiceImpl implements WxRegionService{
    @Autowired
    RegionMapper regionMapper;
    @Override
    public List<Region> list(Integer pid) {
//        List<Region> regions=null;
//        RegionExample regionExample=new RegionExample();
//        if (pid <= 31) {
//            RegionExample.Criteria criteria=regionExample.createCriteria();
//            criteria.andPidEqualTo(pid);
//            regions = regionMapper.selectByExample(regionExample);
//            return regions;
//        }
//        if (pid > 31) {
//            List<Integer> codes=regionMapper.selectCodeByPid(pid);
//            int code = codes.get(0);
//            code/=100;
//            code*=100;
//            regions = regionMapper.selectRegionByCode(code);
//        }
        RegionExample regionExample = new RegionExample();
        RegionExample.Criteria criteria = regionExample.createCriteria();
        criteria.andPidEqualTo(pid);
        List<Region> regions = regionMapper.selectByExample(regionExample);
        return regions;
    }
}
